package com.qf.contorller;

/**
 * @author zdl
 * @date 2025/2/15
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.BuildingMapper;
import com.qf.pojo.Building;
import com.qf.service.BuildingService;
import com.qf.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 楼栋
 */
@RestController
@RequestMapping("/build")
public class BuildingController {
    @Resource
    private BuildingService buildingService;

    @GetMapping("/all")
    public R<PageInfo<Building>> findAllBuilding(@RequestParam int pageNum, @RequestParam int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Building> allBuilding = buildingService.findAllBuilding();
        PageInfo<Building> buildingPageInfo = new PageInfo<>(allBuilding);
        return R.ok(buildingPageInfo);
    }

    @PostMapping("/add")
    public R<Integer> addBuilding(@RequestBody Building building){
        return R.ok(buildingService.addBuilding(building));
    }
    @PostMapping("/delBatch")
    public R<Integer> delBatchRoom(@RequestBody List<Integer> bids){
        return R.ok(buildingService.delBuildingBatch(bids));
    }
}
